<?php
global $userdata, $wpdb;
get_currentuserinfo();
$brukerid = $userdata->ID;
?>

<div id="container">
    <h2>Profil for <?php echo "$userdata->first_name $userdata->last_name" ?></h2>

    <?php echo get_avatar($auser['email'], $size = '125', $default = 'http://i45.tinypic.com/oky8na.jpg'); ?>

    <form method="post" action="?page_id=59" style="margin-bottom: 20px;">
        <input type="submit" value="Endre Profil"/>
    </form>
    <div id="content" role="main">

        <table width="50%" cellspacing="0" cellpadding="0" border="0">
            <tr>
                <td>Navn: </td>
                <td><?php echo $userdata->first_name . " " . $userdata->last_name ?></td>
            </tr>
            <tr>
                <td>Email: </td>
                <td><?php echo $userdata->user_email ?></td>
            </tr>
            <tr>
                <td>Instrument: </td>
                <?php $instrument = get_the_author_meta('instrument', $userdata->ID);
                $res = $wpdb->get_row("SELECT feltdata FROM feltdata WHERE feltdataid ='$instrument'");
                ?>
                <td><?php echo esc_attr($res->feltdata); ?></td>
            </tr>
            <tr>
                <td>Fødselsdag: </td>
                <?php $dato = get_the_author_meta('fødselsdag', $userdata->ID);
                $år = intval(substr($dato, 0, 4));
                $md = intval(substr($dato, 5, 2));
                $dg = intval(substr($dato, 8, 2));
                ?>
                <td><?php echo esc_attr("$dg.$md.$år"); ?></td>
            </tr>
            <tr>
                <td>Adresse: </td>
                <?php $postnr = get_the_author_meta('postnr', $userdata->ID);
                $res = $wpdb->get_row("SELECT stedsnavn FROM poststed WHERE postnr ='$postnr'");
                ?>
                <td><?php echo esc_attr(get_the_author_meta('adresse', $userdata->ID)); ?></br><?php echo esc_attr(get_the_author_meta('postnr', $userdata->ID)) . " " . esc_attr($res->stedsnavn); ?></td>
            </tr>
            <tr>
                <td>Telefon: </td>
                <td><?php echo esc_attr(get_the_author_meta('telefon', $userdata->ID)); ?></td>
            </tr>
            <tr>
                <td>Beskrivelse: </td>
                <td><?php echo esc_attr(get_the_author_meta('description', $userdata->ID)); ?></td>
            </tr>
        </table>
    </div><!-- #content -->

</div><!-- #container -->
